package com.example.demo.model;

public class Json {

    public Long code;
    public String msg;
    public Object data;

    public Json error(String msg, Long code, Object data){
        this.msg = msg;
        this.code = code;
        this.data = data;
        return this;
    }

    public Json error(String msg, Long code){
        this.msg = msg;
        this.code = code;
        return this;
    }

    public Json error(String msg){
        this.msg = msg;
        return this;
    }

    public Json success(Object data, String msg, Long code){
        this.msg = msg;
        this.code = code;
        this.data = data;
        return this;
    }

    public Json success(Object data, String msg){
        this.msg = msg;
        this.code = 200L;
        this.data = data;
        return this;
    }

    public Json success(Object data){
        this.code = 200L;
        this.msg  = "请求成功";
        this.data = data;
        return this;
    }

    public Json success(String msg){
        this.code = 200L;
        this.msg  = msg;
        this.data = null;
        return this;
    }

    public Json setCode(Long code){
        this.code = code;
        return this;
    }

    public Json setMsg(String msg){
        this.msg = msg;
        return this;
    }

    public Json setData(Object data){
        this.data = data;
        return this;
    }

    public Json success(){
        return this;
    }
}
